<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>团购后台管理系统</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<link rel="stylesheet"
	href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="${pageContext.request.contextPath}/js/jqueryui.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script  src="${pageContext.request.contextPath}/js/MD5.js"></script>
<style>
.main_div {
	min-width: 1000px
}

.pageChange {
	padding-left: 20px;
	color: #337ab7;
}

.box_content {
	height: 100px;
	padding-left: 30px
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>
<script>
	$(function() {
	$("#startTime").datepicker();
	$("#endTime").datepicker();
		$("#startTime").datepicker("option","dateFormat","yy-mm-dd");
		$("#endTime").datepicker("option","dateFormat","yy-mm-dd");
	})
</script>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>核销订单</span>
					</div>
					<form class="form-inline" id="detailForm" 
						style="margin-top: 30px;margin-left: 20px">
						<input style="display:none" value="7" id="pageCount"
							name="pageCount" />
 				     	<div class="form-group">
							<label> 请输入秒团核销码：</label> <input type="text"
								class="form-control" id="checkCode">
						</div>												
						<button onclick="selectinfo()" type="button" class="btn btn-primary">立即查询</button>
					</form>
				</div>
				<div class="force-overflow1-1">
					<table id="showtable"
						class="table table-condensed table-bordered table-hover"
						 style="text-align: center">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">订单编号</th>
							<th style="text-align: center">订单状态</th>
							<th style="text-align: center">消费者</th>
							<th style="text-align: center">订单类型</th>
							<th style="text-align: center">订单金额</th>
						    <th style="text-align: center">订单时间</th>
						    <th style="text-align: center">确认核销</th>
						</tr>
					</table>
					<div class="pageChange" style="display:none">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button type="submit" class="btn btn-primary"
							onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>
	</div>
	<script>	
	function selectinfo() {	
	    var pageCount = $("#pageCount").val();
		var pageNum = $("#pageNum").html();
		var checkCode=$("#checkCode").val();
		$.post(urls+"orderFormAction/getOrderFormBySuperInfo",
			{	
			    superId:localStorage.getItem("otherid"),
			    code:checkCode,		
				pageNum : pageNum,
				pageCount :pageCount,
				startTime:null,
				endTime:null
			},
			function(data) {
			//console.log(data)
				if (data) {
				    var totalpage = data.totalpage;
					var orderlist = data.orderlist;					
					var table = $("#showtable");
					$("tr").remove(".addtr");
					for (var i = 0; i < orderlist.length; i++) {
					 var button;
					    var  status=orderlist[i].status;
					    if(status==2){
					     status="未消费"
					     button="<button onclick='sureCheck(\""+ orderlist[i].id+"\")' class='btn btn-primary'>确认核销</button>"
					    }else if(status==3){
					     status="已消费";
					     button="已消费"
					    }else{
					     status=""
					    }
					    var typeId=orderlist[i].typeId
					    if(typeId==0){
					     typeId="秒杀订单"
					    }else if(typeId==2){
					     typeId="团购订单"
					    }else{
					     typeId=""
					    }
					     
						var append = "<tr class='addtr'><td>" + (i + 1) + "</td>"+
						    "<td >" + orderlist[i].orderFormId + "</td>" +
							"<td>" + status + "</td>"+
							"<td>" + orderlist[i].userName + "</td>" +
							"<td>" +typeId + "</td>" +
							"<td>￥" + orderlist[i].totalMoney + "</td>"+
							"<td>" + orderlist[i].orderFormTime + "</td>"+
							"<td>" + button + "</td>"+
							"</tr>";
						table.append(append);
					}
					 $("#totalpage").html(totalpage);
				}
			}
			, "json"
		)
	}
	function sureCheck(id){
	 $.post(urls+"otherAction/verificationCode",{
	   id:id,
	 },function(res){
	 if(res==true){
	  alert("核销成功");
	   selectinfo() 
	 }else{
	 alert("核销失败")
	 }
	 })
	}
</script>
</body>
</html>
